export default {
    createTime(time) {
        let data = new Date(time);
        let dateTimeStamp = data.getTime();
        let min = 1000 * 60;
        let hour = min * 60;
        let day = hour * 24;
        let week = day * 7;
        let month = day * 30;
        let year = month * 12;
        let now = new Date().getTime();
        let diffValue = now - dateTimeStamp;

        let result = "";
        if (diffValue < 0) {
            result = "" + "未来";
        }
        let minC = diffValue / min;
        let hourC = diffValue / hour;
        let dayC = diffValue / day;
        let weekC = diffValue / week;
        let monthC = diffValue / month;
        let yearC = diffValue / year;

        if (yearC >= 1) {
            result = "" + parseInt(yearC) + "年前";
        } else if (monthC >= 1 && monthC < 12) {
            result = "" + parseInt(monthC) + " 个月前";
        } else if (weekC >= 1 && weekC < 5 && dayC > 6 && monthC < 1) {
            result = "" + parseInt(weekC) + "周前";
        } else if (dayC >= 1 && dayC <= 6) {
            result = "" + parseInt(dayC) + "天前";
        } else if (hourC >= 1 && hourC <= 24) {
            result = "" + parseInt(hourC) + "小时前";
        } else if (minC >= 1 && minC <= 59) {
            result = "" + parseInt(minC) + "分钟前";
        } else if (diffValue >= 0 && diffValue <= min) {
            result = "刚刚";
        }
        return result;
    },
}
    //     if (!curTime) {
    //         return ''
    //     }
    //     var nd = new Date(curTime)
    //     var y = nd.getFullYear()
    //     var mm = nd.getMonth() + 1
    //     var d = nd.getDate()
    //     var h = nd.getHours()
    //     var m = nd.getMinutes()
    //     if (mm < 10) {
    //         mm = '0' + mm
    //     }
    //     if (d < 10) {
    //         d = '0' + d
    //     }
    //     if (h < 10) {
    //         h = '0' + h
    //     }
    //     if (m < 10) {
    //         m = '0' + m
    //     }
    //     if (type == 'MM-DD') {
    //         return mm + '-' + d
    //     } else if (type == 'yyyy-MM-dd') {
    //         return y + '-' + mm + '-' + d
    //     } else if (type == 'week') {
    //         return y + '年' + mm + '月' + d + '日　' + weekDay[nd.getDay()]
    //     } else if (type == 'MM-DD&week') {
    //         return mm + '-' + d + ' ' + weekDay[nd.getDay()]
    //     } else if (type == 'MM-DD&hh:mm') {
    //         return mm + '-' + d + ' ' + h + ':' + m
    //     } else if (type == '年月日') {
    //         return y + '年' + mm + '月' + d + '日　'
    //     } else if (type == 'yyyy.MM.dd&hh:mm') {
    //         return y + '.' + mm + '.' + d + ' ' + h + ':' + m
    //     }
    //     else if (type == 'yyyy.MM.dd&hh:mm:ss') {
    //         return y + '.' + mm + '.' + d + ' ' + h + ':' + m + ':' + s
    //     }
    //     return y + '-' + mm + '-' + d + ' ' + h + ':' + m
    // },